// @Author EthanScriptOn
// @Desc
package operator

import (
	"fmt"
	"gitee.com/fatzeng/srf_switch_basic_components/manager"
	"gitee.com/fatzeng/srf_switch_basic_components/switch_log"
)

var OperatorConfigCenter = new(manager.ResourceManager)

func AddOperatorConfig(operatorConfigInstance MultiChannelDataOperatorConfigInterface) (err error) {
	if operatorConfigInstance == nil {
		return fmt.Errorf("cannot add, MultiChannelDataOperatorConfigInterface is nil")
	}
	return OperatorConfigCenter.AddResource(operatorConfigInstance)
}

func GetOperatorConfig(operatorConfigIdentifier interface{}) MultiChannelDataOperatorConfigInterface {
	resource := OperatorCenter.GetResource(operatorConfigIdentifier)
	if resource == nil {
		switch_log.Logger().Error("GetOperatorConfig failed unable to obtain message is: ", operatorConfigIdentifier)
		return nil
	}
	configInterface, ok := resource.(MultiChannelDataOperatorConfigInterface)
	if ok {
		return configInterface
	}
	switch_log.Logger().Error("Not of type MultiChannelDataOperatorConfigInterface message is: ", operatorConfigIdentifier)
	return nil
}
